<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('hot_searches', function (Blueprint $table) {
            $table->id();
            $table->string('keyword')->unique()->comment('搜索关键词');
            $table->integer('search_count')->default(1)->comment('搜索次数');
            $table->integer('click_count')->default(0)->comment('点击次数');
            $table->timestamp('last_searched_at')->nullable()->comment('最后搜索时间');
            $table->timestamps();
            
            $table->index('search_count');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('hot_searches');
    }
};
